import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ApiProgramVO, ApiProgramForm, ApiProgramQuery } from '@/api/provider/apiProgram/types';

/**
 * 查询上游供应商连接程序列表
 * @param query
 * @returns {*}
 */

export const listApiProgram = (query?: ApiProgramQuery): AxiosPromise<ApiProgramVO[]> => {
  return request({
    url: '/provider/apiProgram/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询上游供应商连接程序列表
 * @param query
 * @returns {*}
 */

export const listAllApiProgram = (): AxiosPromise<ApiProgramVO[]> => {
  return request({
    url: '/provider/apiProgram/list',
    method: 'get'
  });
};

/**
 * 查询上游供应商连接程序详细
 * @param id
 */
export const getApiProgram = (id: string | number): AxiosPromise<ApiProgramVO> => {
  return request({
    url: '/provider/apiProgram/' + id,
    method: 'get'
  });
};

/**
 * 新增上游供应商连接程序
 * @param data
 */
export const addApiProgram = (data: ApiProgramForm) => {
  return request({
    url: '/provider/apiProgram',
    method: 'post',
    data: data
  });
};

/**
 * 修改上游供应商连接程序
 * @param data
 */
export const updateApiProgram = (data: ApiProgramForm) => {
  return request({
    url: '/provider/apiProgram',
    method: 'put',
    data: data
  });
};

/**
 * 删除上游供应商连接程序
 * @param id
 */
export const delApiProgram = (id: string | number | Array<string | number>) => {
  return request({
    url: '/provider/apiProgram/' + id,
    method: 'delete'
  });
};
